package com.lsh.manger.factory;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.TimerTask;

/**
 * @author ：LiuShihao
 * @date ：Created in 2021/5/19 5:27 下午
 * @desc ：异步工厂（产生任务用）
 */
@Slf4j
public class AsyncFactory {

    public static TimerTask testAsynTask(LocalDateTime start){
        //TODO
        return new TimerTask() {
            @SneakyThrows
            @Override
            public void run() {
                DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                Thread.sleep(1000);
                String now = LocalDateTime.now().format(pattern);
                String startStr = start.format(pattern);
                System.out.println("start : "+startStr +"  ; now : "+now);
            }
        };

    }
}
